package com.hxk.tx;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Random;
import java.util.UUID;

@Repository
public class TestDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public int insertData(){
        String sql = "INSERT INTO t_test (name, age) VALUES (?,?)";
        String name = UUID.randomUUID().toString().substring(0,5);
        int age = new Random().nextInt(30);
        return jdbcTemplate.update(sql,name,age);
    }
}
